package com.yuzhitong.shapi.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yuzhitong.shapi.BuildConfig;
import com.yuzhitong.shapi.R;
import a.a.a.MyApplication;
import com.yuzhitong.shapi.base.BaseLayoutActivity;

/**
 * Created by Brsya
 * CreateDate: 2022/4/26  19:16
 * Description:
 * 关于我们
 */
public class AboutActivity extends BaseLayoutActivity {

    private RelativeLayout llPageTitleBox;
    private TextView tvPageTitle;
    private LinearLayout llTitleBackBox;
    private LinearLayout llAboutBox;
    private TextView tvVersion;
    private LinearLayout llEmailBox;
    private TextView tvEmail;
    private LinearLayout llVersionBox;
    private View vLogo;

    private long clickTime = -1;
    private long clickNumber = 0;
    private LinearLayout llAndroidIdBox;
    private TextView tvAndroidId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        setDarkStatus();
        initView();
    }

    private void initView() {
        llPageTitleBox = findViewById(R.id.ll_page_title_box);
        tvPageTitle = findViewById(R.id.tv_page_title);
        llTitleBackBox = findViewById(R.id.ll_title_back_box);
        llAboutBox = findViewById(R.id.ll_version_box);
        tvVersion = findViewById(R.id.tv_version);
        llEmailBox = findViewById(R.id.ll_email_box);
        tvEmail = findViewById(R.id.tv_email);
        llVersionBox = findViewById(R.id.ll_version_box);
        vLogo = findViewById(R.id.v_logo);
        llAndroidIdBox = findViewById(R.id.ll_android_id_box);
        tvAndroidId = findViewById(R.id.tv_android_id);

        llPageTitleBox.setPadding(
                llPageTitleBox.getPaddingLeft(),
                llPageTitleBox.getPaddingTop() + getStatusBarHeight(),
                llPageTitleBox.getPaddingRight(),
                llPageTitleBox.getPaddingBottom()
        );

        tvVersion.setText(BuildConfig.VERSION_NAME);
        tvEmail.setText(R.string.about_email_value);

        llTitleBackBox.setOnClickListener(v -> finish());

        tvAndroidId.setText(String.valueOf(MyApplication.androidId));
        vLogo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                long time = System.currentTimeMillis();

                if (time - clickTime > 60 * 1000) {
                    clickTime = time;
                    clickNumber = 0;
                    return;
                }

                clickNumber++;
                if (10 > clickNumber) {
                    return;
                }

                llAndroidIdBox.setVisibility(View.VISIBLE);
            }
        });
    }
}
